from aiohttp.web_response import Response
from celery import shared_task
from utils.MyRedis import r
from utils.beidu import Baidu


@shared_task
def bdcardmes():
    # 读取redis list 取出3条
    list = r.list_lrange('beidulist',0,2)
    for i in list:
        picurl = i.decode()
        # 调用百度接口
        bdapi = Baidu()
        data = bdapi.idcard(picurl)
        # 存入redis
        r.set_str(picurl,str(data))
    # 删除队列
    r.list_pop('beidulist')

